<%@ Page Language="C#" AutoEventWireup="true" Codebehind="ListForms.aspx.cs" Inherits="EPFormsGeneratorControls.FormsGenerator.Plugins.ListForms1" %>

<%@ Register TagPrefix="EPiServer" Namespace="EPiServer.WebControls" Assembly="EPiServer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>List Forms</title>
    <link rel="stylesheet" type="text/css" href="../../util/styles/system.css">

    <script type='text/javascript' src="../../util/javascript/system.js"></script>

    <script type='text/javascript'>
    function updateAndClose(formGuid, formName)
    {
        if (window.opener != null)
        {
            var returnValues = new Array();
            returnValues["formName"] = formName;
            returnValues["formGuid"] = formGuid;
            window.opener.updateFormsGeneratorValues(returnValues);
            window.close();
        }
        else
        {
            alert('<EPiServer:Translate ID="Translate5" Text="/formsgeneratorcontrols/messages/errorselectform" runat="server" />');
        }
    }
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Label ID="LabelMessage" runat="server" ForeColor="#FF0000" Visible="false" EnableViewState="false"></asp:Label>
            <div style="float: left">
                <h3>
                    FormsGenerator</h3>
            </div>
            <div style="float: right; text-align: right; margin-bottom: 1em;">
                <EPiServer:Translate ID="Translate1" Text="/formsgeneratorcontrols/user" runat="server" /><asp:Label
                    ID="LabelUserId" runat="server"></asp:Label><br />
                <br />
                <input id="ButtonResfresh" type="button" value="Refresh list" onclick='window.location.href=window.location.href'
                    runat="server" />
                <input id="ButtonNewForm" type="button" value="New Form" onclick='window.open("<%=FormsGeneratorUrl%>/EditForm.aspx", "formedit", "toolbar=no,titlebar=no,resizable=yes,scrollbars=yes")'
                    runat="server" />
            </div>
            <asp:GridView CssClass="EP-tableGrid" Width="100%" ID="GridViewForms" runat="server"
                OnRowDataBound="GridViewForms_RowDataBound" OnRowCommand="GridViewForms_RowCommand"
                AutoGenerateColumns="false">
                <Columns>
                    <asp:TemplateField HeaderStyle-CssClass="EP-tableHeadingGrid">
                        <ItemTemplate>
                            <input type="button" id="ButtonSelect" runat="server" value="Select Form" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderStyle-CssClass="EP-tableHeadingGrid" ReadOnly="true" DataField="guid"
                        HeaderText="Id" />
                    <asp:BoundField HeaderStyle-CssClass="EP-tableHeadingGrid" ReadOnly="true" DataField="Name"
                        HeaderText="Name" />
                    <asp:BoundField HeaderStyle-CssClass="EP-tableHeadingGrid" ReadOnly="true" DataField="Owner"
                        HeaderText="Created by" />
                    <asp:BoundField HeaderStyle-CssClass="EP-tableHeadingGrid" ReadOnly="true" DataField="CreatedDate"
                        HtmlEncode="false" HeaderText="Created Date" DataFormatString="{0:dd.MM.yyyy}" />
                    <asp:TemplateField HeaderText="Results" HeaderStyle-CssClass="EP-tableHeadingGrid"
                        Visible="True">
                        <ItemTemplate>
                            <a href="#" id="HyperLinkDetails" runat="server" onclick='<%# "window.open(\"" + FormsResultsUrl + "?id=" + Eval("guid") + "\",\"FormResults\", \"toolbar=yes,titlebar=no,resizable=yes,width=800,height=600,scrollbars=yes\");" %>'>
                                [<EPiServer:Translate ID="Translate1" Text="/formsgeneratorcontrols/button/viewresults"
                                    runat="server" />]</a>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-CssClass="EP-tableHeadingGrid" HeaderText="Forms actions">
                        <ItemTemplate>
                            <input type="button" id="ButtonEdit" runat="server" visible="false" value="Edit" />
                            <asp:Button ID="ButtonDelete" runat="server" Visible="false" Text="Delete" CommandName="DeleteForm"
                                CommandArgument='<%# Eval("guid") %>'></asp:Button>
                            <input type="button" id="ButtonAccess" runat="server" visible="false" value="Access" />
                            <asp:Button ID="ButtonUnlock" runat="server" Visible="false" Text="Unlock" CommandName="Unlock"
                                CommandArgument='<%# Eval("guid") %>'></asp:Button>
                            <asp:Button ID="ButtonLock" runat="server" Visible="false" Text="Lock" CommandName="Lock"
                                CommandArgument='<%# Eval("guid") %>'></asp:Button>
                            <asp:Literal ID="LiteralMessage" Visible="false" runat="server"></asp:Literal>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
    </form>
</body>
</html>
